package foo.bar.wiki.web.action.space;

import foo.bar.wiki.web.action.BaseActionBean;
import foo.bar.wiki.web.action.PaginatedBaseActionBean;
import foo.bar.wiki.web.action.ExtendedPaginatedList;
import foo.bar.wiki.web.extension.SpaceTypeConverter;
import foo.bar.wiki.domain.Space;
import foo.bar.wiki.services.WikiService;
import net.sourceforge.stripes.action.Resolution;
import net.sourceforge.stripes.action.ForwardResolution;
import net.sourceforge.stripes.action.DefaultHandler;
import net.sourceforge.stripes.validation.Validate;
import net.sourceforge.stripes.integration.spring.SpringBean;
import org.apache.commons.logging.LogFactory;
import org.apache.commons.logging.Log;

/**
 * @author tmjee
 * @version $Date$ $Id$
 */
public class ViewSpaceActionBean extends PaginatedBaseActionBean {

    private static final Log LOG = LogFactory.getLog(ViewSpaceActionBean.class);

    public static final String VIEW = "/space/viewSpace.jsp";

    private WikiService wikiService;


    @Validate(converter = SpaceTypeConverter.class)
    private Space space;

    private ExtendedPaginatedList pages;

    @DefaultHandler
    public Resolution view() {
        pages = getPaginatedList("space_pages_"+space.getId());
        pages = wikiService.getSpacePages(space, pages);
        
        return new ForwardResolution(generateThemePath(VIEW));
    }





    @SpringBean("wikiService")
    public void setWikiService(WikiService wikiService) {
        this.wikiService = wikiService;
    }


    public Space getSpace() {
        return space;
    }

    public void setSpace(Space space) {
        this.space = space;
    }


    public ExtendedPaginatedList getPages() {
        return pages;
    }

    public void setPages(ExtendedPaginatedList pages) {
        this.pages = pages;
    }
}
